
angular.module('zixys.export',[])

    .directive('exportTab',function(){
        return {
            restrict: 'C',
            replace: false,
            scope: {},
            template:							
                        '<div id="zixys-export-tab" >'+
                            '<div class="zixys-menu-block">'+
                                '<div class="zixys-input-box"><input type="button" value="Export" ng-click="export()"></div>'+
                            '</div>'+
                        '</div>',

            link: function($scope, element, attrs) {

            },
            controller:['$scope','$rootScope',function($scope,$rootScope){
                //console.log($rootScope);
                $scope.export = function(){
                    var tempNode;
                    var output = '';


                    for (var key in $rootScope.nodes) {
                        tempNode = $rootScope.nodes[key];
                        output = output + tempNode.outputNode.html() + '\n';
                    }

                    console.log(output);
                }
            }]
        }
    })

    .run(['$rootScope',function($rootScope) {
        
        $rootScope.$on('zixysDomReady',function(event,params){
            $rootScope.addTab('Export','export-tab');
        });
        
    }]);
    
    